﻿using System.Collections.Generic;
using System.ServiceModel.Activation;

namespace Prompts.Service.PromptService
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class PromptSelectionService : IPromptSelectionService
    {
         private readonly IBaseReportParameterService _parameterService;
         private readonly ISelectionParameterValueBuilder _selectionParameterValueBuilder;
         private readonly IPromptSelectionsProvider _promptSelectionsProvider;

         public PromptSelectionService(
            IBaseReportParameterService parameterService
            , ISelectionParameterValueBuilder selectionParameterValueBuilder
            , IPromptSelectionsProvider promptSelectionsProvider)
         {
             _promptSelectionsProvider = promptSelectionsProvider;
             _selectionParameterValueBuilder = selectionParameterValueBuilder;
             _parameterService = parameterService;
         }

         public string SetPromptSelections(string path, IEnumerable<PromptSelectionInfo> promptSelections)
         {
             var selections = _promptSelectionsProvider.Get(promptSelections);
             var baseReportParameters = _parameterService.GetParametersFor(path);
             var parameterValues = _selectionParameterValueBuilder.Get(baseReportParameters, selections);

             return _parameterService.SetParameters(parameterValues);
         }
    }
}
